package com.ist.viewpagerhelper;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.widget.Scroller;

import java.lang.reflect.Field;

public class FixedSpeedScroller {
    private Context mContext;
    private int time;
    public FixedSpeedScroller(Context context,ViewPager viewPager,int time) {
        mContext = context;
        this.time = time;
        try {
            Field field = ViewPager.class.getDeclaredField("mScroller");
            field.setAccessible(true);
            field.set(viewPager,bannerScroller);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }




    private Scroller bannerScroller = new Scroller(mContext){
        @Override
        public void startScroll(int startX, int startY, int dx, int dy, int duration) {
            super.startScroll(startX, startY, dx, dy, time);
        }

        @Override
        public void startScroll(int startX, int startY, int dx, int dy) {
            super.startScroll(startX, startY, dx, dy,time);
        }
    };

}  